package ThreadDemo2;

/**
 * @Author: ylc
 * @Description:创建多线程的第二种方式：实现Runnable接口
 * @Date Created in 2022-04-20 11:02
 */
public class ThreadDemo2 {
    public static void main(String[] args) {
        //创建Runnable接口的实现类对象
        RunnableImpl thread2 = new RunnableImpl();
        //创建Thread实例对象，构造方法中传入Runnable接口实例对象
        Thread t = new Thread(thread2);

        //调用start方法
        t.start();
        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName() + " " + i);
        }
    }
}
